<template>
  <div class="search">
    <div id="main">
      <div id="foods">
        <div id="searchNum">
          <el-page-header @back="goBack" :content="'共'+menu.length/3+'个搜索结果》》'"></el-page-header>
        </div>
        <div class="nybasetit grid-content">
          <div class="yezi"></div>
        </div>
        <ul id="foodsList">
          <li v-for="(list,index) in menu" :key="index" v-if="index%3==0">
            <p>Top{{(index+3)/3}}</p>
            <p>{{list.mealTitle}}</p>
            <p>{{menu[index].menuName}}</p>
            <p>{{menu[index+1].menuName}}</p>
            <p>{{menu[index+2].menuName}}</p>
            <p>
              <router-link :to="'/index/top/mealId/' + menu[index].mealId">>>详情</router-link>
            </p>
          </li>
        </ul>
        <ul id="pagesList"></ul>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      menu: []
    };
  },
  created() {
    console.log(this.$route.params);
    this.$axios
      .get("http://localhost:3000/search/" + this.$route.params.searchcontent)
      .then(res => {
        console.log(res.data.data);
        this.menu = res.data.data;
        this.search = "";
      })
      .catch(err => {
        console.log("错误信息：", err);
      });
  },
  methods: {
    goBack() {
      this.$router.push("/index/home");
    }
  }
};
</script>
<style lang="css" scoped>
.el-page-header {
  margin-top: 20px;
}
#main {
  width: 80%;
  margin: auto;
}

#foods {
  width: 100%;
  margin: 10px auto;
}

.nybasetit {
  text-align: center;
}

.nybasetit h3 {
  font-size: 42px;
  font-family: arial;
  color: #111;
  margin-top: 30px;
}

.nybasetit span {
  font-size: 16px;
  display: block;
}

.nybasetit img {
  margin: 30px 0;
}

#main .nybasetit .yezi {
  height: 40px;
  background: url(../assets/images/base1.png) no-repeat center;
  margin: 30px 0;
}

#foods #foodsList {
  float: left;
  width: 100%;
}

#foods #foodsList li {
  position: relative;
  float: left;
  width: 22%;
  height: 250px;
  margin-left: 30px;
  margin-top: 30px;
  border: 1px solid rgb(160, 190, 117);
  cursor: pointer;
  background: url(../assets/images/bgtop.png) 100% 100% / cover no-repeat;
  background-size: 50%;
  background-color: #61b662;
}

#foods #foodsList li p {
  height: 35px;
  line-height: 35px;
  text-align: center;
  font-size: 16px;
  color: #fff;
}

#foods #foodsList li p:first-child {
  position: relative;
  font-size: 25px;
  font-weight: bolder;
  color: orangered;
}
#foods #foodsList li p:last-child {
  display: none;
}
#foods #foodsList li:hover p:last-child {
  display: block;
  position: absolute;
  top: 0;
  width: 100%;
  height: 100%;
  line-height: 250px;
  background-color: rgba(90, 90, 90, 0.8);
  text-align: center;
}

#foods #foodsList li p:nth-child(2) {
  font-size: 20px;
  font-weight: bolder;
  color: orangered;
}

#foods #foodsList li p a {
  font-weight: bolder;
  color: #ddd;
}
</style>